home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / RAND / UNSPLIT / BM214SRC.ZIP / 68030 / TEXTURES.S < prev   
Encoding:
Text File  |  1996-06-29  |  20.2 KB  |  715 lines

  1. *=======================================================*
  2. *    Texture module: latest update 25/03/96        *
  3. *=======================================================*
  4. *    Process, reformat, build & manage textures    *
  5. *=======================================================*
  6.  
  7. max_hash    =    4096        ; maximum number of hash entries
  8. max_textures    =    512        ; maximum number of textures in WAD
  9. max_graphics    =    2048        ; maximum number of textures in WAD
  10.  
  11. max_patches    =    72        ; maximum patches per texture
  12.  
  13. ;sky_colour    =    216        ; hack for sky colour
  14.  
  15. sky_colour    =    56        ; hack for sky colour
  16.  
  17. ;sky_colour    =    211        ; hack for sky colour
  18. upper_sky_lum    =    180
  19. upper_sky_dist    =    -64
  20. lower_sky_lum    =    180
  21. lower_sky_dist    =    64
  22.  
  23. texcode_none    =    -1
  24. texcode_sky    =    -2
  25. texcode_qalpha    =    -3
  26.  
  27. *-------------------------------------------------------*
  28. *    Read & convert texture resource directories    *
  29. *-------------------------------------------------------*
  30. init_textures:
  31. *-------------------------------------------------------*
  32. *    Set up list & resource pointers            *
  33. *-------------------------------------------------------*
  34.     move.l        #graphics_space,graphics_array
  35.     move.l        #graphics_space,floating_array
  36.     move.l        #texture_space,texture_array
  37.     move.l        #pnamelist_space,pnamelist_array
  38.     clr.w        graphics_count
  39.     clr.w        flat_count
  40.     clr.w        texture_count
  41.     sf        textures_present
  42. *-------------------------------------------------------*
  43. *    Remove unwanted sidedef textures from sky    *
  44. *-------------------------------------------------------*
  45. ;    bsr        fix_sky_textures
  46. *-------------------------------------------------------*
  47. *    Patch alpha textures                *
  48. *-------------------------------------------------------*
  49.     bsr        patch_alpha_textures
  50. *-------------------------------------------------------*
  51. *    Replace flat texture references with indexes    *
  52. *-------------------------------------------------------*
  53.     move.l        floating_array,flatlist_array
  54.     bsr        replace_flats
  55. *-------------------------------------------------------*
  56. *    Read texture directory structures        *
  57. *-------------------------------------------------------*
  58.     move.l        floating_array,texturelist_array
  59.     bsr        read_pnames
  60.     Cconws        #ascii_readtex1
  61.     lea        ascii_texture1,a0
  62.     bsr        add_textures
  63.     Cconws        #ascii_readtex2
  64.     lea        ascii_texture2,a0
  65.     bsr        add_textures
  66.     tst.b        textures_present
  67.     bne        .cont
  68.     Cconws        #ascii_err_notex
  69.     bra.s        .go
  70. *-------------------------------------------------------*
  71. *    Build hash table for textures            *
  72. *-------------------------------------------------------*
  73. .cont:    bsr        build_texture_hash
  74. *-------------------------------------------------------*
  75. *    Find sky textures                *
  76. *-------------------------------------------------------*
  77.     lea        ascii_sky1,a0
  78.     bsr        find_texture_index
  79.     move.w        d0,sky1_index
  80.     bmi.s        .n1
  81.     move.w        d0,current_sky
  82. .n1:    lea        ascii_sky2,a0
  83.     bsr        find_texture_index
  84.     move.w        d0,sky2_index
  85.     bmi.s        .n2
  86.     move.w        d0,current_sky
  87. .n2:    lea        ascii_sky3,a0
  88.     bsr        find_texture_index
  89.     move.w        d0,sky3_index
  90.     bmi.s        .n3
  91.     move.w        d0,current_sky
  92. .n3:    lea        ascii_sky4,a0
  93.     bsr        find_texture_index
  94.     move.w        d0,sky4_index
  95.     bmi.s        .go
  96.     move.w        d0,current_sky
  97. *-------------------------------------------------------*
  98. *    Replace wall texture references with indexes    *
  99. *-------------------------------------------------------*
  100. .go:    bsr        replace_textures
  101. *-------------------------------------------------------*
  102.     bsr        organise_patches
  103. *-------------------------------------------------------*
  104.     rts
  105.  
  106. *-------------------------------------------------------*
  107. *    Create tracking list for patches        *
  108. *-------------------------------------------------------*
  109. organise_patches:
  110. *-------------------------------------------------------*
  111.     bsr        build_directory_hash
  112.     Cconws        #ascii_locatepatch
  113.     move.l        pname_ptr,a3
  114.     move.l        pnamelist_array,a6
  115.     move.w        pname_count,d7
  116.     bra.s        .go
  117. .all:    move.l        a3,a0
  118.     bsr        locate_entry
  119. .cont:    move.l        d0,(a6)+
  120.     addq.l        #8,a3
  121. .go:    dbra        d7,.all
  122.     rts
  123.  
  124. *-------------------------------------------------------*
  125. *    Create hashtable to reduce search overheads    *
  126. *-------------------------------------------------------*
  127. build_flat_hash:
  128. *-------------------------------------------------------*
  129. *    Track down 'f_start' & 'f_end' markers        *
  130. *-------------------------------------------------------*
  131.     st        flats_present
  132.     lea        ascii_fstart,a0
  133.     bsr        place_marker
  134.     move.l        wad_mdirectory,flat_start
  135.     tst.w        d0
  136.     beq.s        .err
  137.     lea        ascii_fend,a0
  138.     push.l        all_directory
  139.     push.l        all_entries    
  140.     move.l        wad_mdirectory,all_directory
  141.     move.l        wad_mentries,all_entries    
  142.     bsr        place_marker
  143.     pop.l        all_entries
  144.     pop.l        all_directory
  145.     move.l        wad_mdirectory,flat_end
  146.     tst.w        d0
  147.     bne.s        .cont
  148. .err:    Cconws        #ascii_err_noflats
  149.     sf        flats_present
  150.     bra        .exit
  151. *-------------------------------------------------------*
  152. *    Create hashtable for all valid entries        *
  153. *-------------------------------------------------------*
  154. .cont:    bsr        empty_hash
  155.     move.l        flat_end,d7
  156.     move.l        flat_start,a0
  157.     sub.l        a0,d7
  158.     divu.l        #wd_len,d7
  159.     move.l        hash_array,a2
  160.     move.l        floating_array,a3
  161.     bra.s        .go
  162. *-------------------------------------------------------*
  163. .all:
  164. *-------------------------------------------------------*
  165.     movem.l        d1-d7/a0-a6,-(sp)
  166.     lea        wd_name(a0),a1
  167.     lea        ascii_sky,a0
  168.     bsr        strcmp_8
  169.     movem.l        (sp)+,d1-d7/a0-a6
  170.     tst.w        d0
  171.     beq.s        .nsky
  172. *-------------------------------------------------------*
  173. *    Keep track of sky index                *
  174. *-------------------------------------------------------*
  175.     move.l        a3,d0
  176.     sub.l        graphics_array,d0
  177.     lsr.l        #2,d0
  178.     move.w        d0,sky_index
  179. *-------------------------------------------------------*
  180. *    Generate hash index for entry            *
  181. *-------------------------------------------------------*
  182. .nsky:    lea        wd_name(a0),a1
  183.     bsr        hash_name
  184. *-------------------------------------------------------*
  185. *    Store reference in hash table            *
  186. *-------------------------------------------------------*
  187.     move.w        #max_hash-1,d4
  188. .find:    and.w        #max_hash-1,d1
  189.     tst.l        (a2,d1.w*4)
  190.     beq.s        .slot
  191.     addq.w        #1,d1
  192.     dbra        d4,.find
  193. .slot:    move.l        a3,(a2,d1.w*4)
  194. *-------------------------------------------------------*
  195. *    Store index & directory in reference list    *
  196. *-------------------------------------------------------*
  197.     move.l        a0,(a3)+
  198. *-------------------------------------------------------*
  199. *    Store type in cache slot            *
  200. *-------------------------------------------------------*
  201.     move.w        graphics_count,d4
  202.     lea        cache_slots,a1
  203.     mulu.w        #cache_slen,d4
  204.     move.w        #ctype_raw,cache_type(a1,d4.l)
  205.     addq.w        #1,flat_count
  206.     addq.w        #1,graphics_count
  207. *-------------------------------------------------------*
  208. .next:    lea        wd_len(a0),a0
  209. .go:    dbra        d7,.all
  210.     move.l        a3,floating_array
  211. .exit:    rts
  212.  
  213. *-------------------------------------------------------*
  214. *    Remove upper / lower names from sky linedefs    *
  215. *-------------------------------------------------------*
  216. fix_sky_textures:
  217. *-------------------------------------------------------*
  218.     Cconws        #ascii_fixsky
  219. *-------------------------------------------------------*
  220.     move.l        Line_Array,a2
  221.     move.l        Side_Array,a6
  222.     move.w        NumLines,d7
  223.     bra        .lines
  224. *-------------------------------------------------------*
  225. .line:    move.w        linedef_left(a2),d0
  226.     bmi        .err
  227.     mulu.w        #sidedef_len,d0
  228.     lea        (a6,d0.l),a4            ; left sidedef
  229.     move.w        linedef_right(a2),d0
  230.     bmi        .err
  231.     mulu.w        #sidedef_len,d0
  232.     lea        (a6,d0.l),a3            ; right sidedef
  233. *-------------------------------------------------------*
  234.     push.l        a6
  235. *-------------------------------------------------------*
  236.     move.l        Sector_Array,a0
  237.     move.w        sidedef_sector(a4),d0
  238.     mulu.w        #sector_len,d0
  239.     lea        (a0,d0.l),a6            ; left sector
  240.     move.w        sidedef_sector(a3),d0
  241.     mulu.w        #sector_len,d0
  242.     lea        (a0,d0.l),a5            ; right sector
  243. *-------------------------------------------------------*
  244.     lea        ascii_sky,a0
  245.     lea        sector_ctns(a5),a1
  246.     bsr        strcmp_8
  247.     tst.w        d0
  248.     beq.s        .no_upper_sky
  249.     lea        sector_ctns(a6),a1
  250.     bsr        strcmp_8
  251.     tst.w        d0
  252.     beq.s        .no_upper_sky
  253. *-------------------------------------------------------*
  254.     lea        sidedef_utns(a4),a0
  255.     bsr        sky_name
  256.     lea        sidedef_utns(a3),a0
  257.     bsr        sky_name
  258. *-------------------------------------------------------*
  259. .no_upper_sky:
  260. *-------------------------------------------------------*
  261.     lea        ascii_sky,a0
  262.     lea        sector_ftns(a5),a1
  263.     bsr        strcmp_8
  264.     tst.w        d0
  265.     beq.s        .no_lower_sky
  266.     lea        sector_ftns(a6),a1
  267.     bsr        strcmp_8
  268.     tst.w        d0
  269.     beq.s        .no_lower_sky
  270. *-------------------------------------------------------*
  271.     lea        sidedef_ltns(a4),a0
  272.     bsr        sky_name
  273.     lea        sidedef_ltns(a3),a0
  274.     bsr        sky_name
  275. *-------------------------------------------------------*
  276. .no_lower_sky:
  277. *-------------------------------------------------------*
  278.     pop.l        a6
  279. *-------------------------------------------------------*
  280. .err:    lea        linedef_len(a2),a2
  281. .lines:    dbra        d7,.line
  282.     rts
  283.  
  284.  
  285. *-------------------------------------------------------*
  286. *    Patch quick-alpha textures            *
  287. *-------------------------------------------------------*
  288. patch_alpha_textures:
  289. *-------------------------------------------------------*
  290.     Cconws        #ascii_patchalpha
  291.     move.l        Side_Array,a3
  292.     move.w        NumSides,d7
  293.     bra.s        .segs
  294. .seg:
  295. ;    lea        sidedef_utns(a3),a1
  296. ;    bsr        alpha_check
  297. ;    lea        sidedef_ltns(a3),a1
  298. ;    bsr        alpha_check
  299.     lea        sidedef_mtns(a3),a1
  300.     bsr        alpha_check
  301.     lea        sidedef_len(a3),a3
  302. .segs:    dbra        d7,.seg
  303.     rts
  304.  
  305. *-------------------------------------------------------*
  306. alpha_check:
  307. *-------------------------------------------------------*
  308.     lea        ascii_qalpha,a0
  309.     bsr        strcmp_8
  310.     tst.w        d0
  311.     beq.s        .not_alpha
  312. *-------------------------------------------------------*
  313. *    Alpha texture detected                *
  314. *-------------------------------------------------------*
  315.     move.w        #'~q',(a1)+
  316.     clr.w        (a1)+
  317.     clr.l        (a1)+
  318. *-------------------------------------------------------*
  319. .not_alpha:
  320. *-------------------------------------------------------*
  321.     rts
  322.  
  323. *-------------------------------------------------------*
  324. *    Trash texture name                *
  325. *-------------------------------------------------------*
  326. sky_name:
  327. *-------------------------------------------------------*
  328.     move.w        #'~s',(a0)+
  329.     clr.w        (a0)+
  330.     clr.l        (a0)+
  331.     rts
  332.  
  333. *-------------------------------------------------------*
  334. *    Replace flat names with quick-index values    *
  335. *-------------------------------------------------------*
  336. replace_flats:
  337. *-------------------------------------------------------*
  338.     bsr        build_flat_hash
  339.     Cconws        #ascii_replaceflat
  340.     move.l        Sector_Array,a3
  341.     move.w        NumSectors,d7
  342.     bra.s        .segs
  343. .seg:    lea        sector_ctns(a3),a0
  344.     bsr.s        replace_flatname
  345.     lea        sector_ftns(a3),a0
  346.     bsr.s        replace_flatname
  347.     lea        sector_len(a3),a3
  348. .segs:    dbra        d7,.seg
  349.     rts
  350.  
  351. *-------------------------------------------------------*
  352. *    Replace flat name with quick-index        *
  353. *-------------------------------------------------------*
  354. replace_flatname:
  355. *-------------------------------------------------------*
  356.     cmp.b        #'-',(a0)
  357.     beq.s        .none
  358.     move.l        a0,a1
  359.     bsr        hash_name
  360.     move.l        hash_array,a2
  361.     move.w        #max_hash-1,d4
  362. .find:    and.w        #max_hash-1,d1
  363.     move.l        (a2,d1.w*4),d5
  364.     beq.s        .err
  365.     move.l        d5,a4
  366.     move.l        (a4),a1
  367.     lea        wd_name(a1),a1
  368.     bsr        strcmp_8
  369.     tst.w        d0
  370.     beq.s        .cont
  371.     sub.l        graphics_array,d5
  372.     lsr.l        #2,d5
  373.     move.w        d5,(a0)+
  374.     bra.s        .done
  375. .cont:    addq.w        #1,d1
  376.     dbra        d4,.find
  377. .err:    clr.w        (a0)+
  378.     bra.s        .done
  379. .none:    move.w        #-1,(a0)+
  380. .done:    clr.w        (a0)+
  381.     clr.l        (a0)+
  382.     rts
  383.  
  384. *-------------------------------------------------------*
  385. *    Load PNAME resource from WAD            *
  386. *-------------------------------------------------------*
  387. read_pnames:
  388. *-------------------------------------------------------*
  389.     Cconws        #ascii_readpnames
  390.     lea        ascii_pnames,a0
  391.     bsr        load_resource
  392.     tst.l        d0
  393.     beq        err_missing
  394.     imov.l        (a6)+,d0
  395.     move.w        d0,pname_count
  396.     move.l        a6,pname_ptr
  397.     rts
  398.  
  399. *-------------------------------------------------------*
  400. *    Process texture directory            *
  401. *-------------------------------------------------------*
  402. add_textures:
  403. *-------------------------------------------------------*
  404.     bsr        load_resource
  405.     tst.l        d0
  406.     beq.s        .err1
  407.     move.l        a6,resource_ptr
  408.     move.l        texture_array,a4
  409.     move.l        floating_array,a5
  410.     imov.l        (a6)+,d6
  411.     bra.s        .texs
  412. .tex:    imov.l        (a6)+,a0
  413.     add.l        resource_ptr,a0
  414.     bsr        store_texturedef    
  415.     addq.w        #1,graphics_count
  416.     addq.w        #1,texture_count
  417. .texs:    dbra        d6,.tex
  418.     move.l        a5,floating_array
  419.     move.l        a4,texture_array
  420.     Mfree        resource_ptr
  421.     st        textures_present
  422. .err1:    rts
  423.  
  424. *-------------------------------------------------------*
  425. *    Transfer texture definition to new array    *
  426. *-------------------------------------------------------*
  427. store_texturedef:
  428. *-------------------------------------------------------*
  429. *    Store type in cache slot            *
  430. *-------------------------------------------------------*
  431.     move.w        graphics_count,d0
  432.     lea        cache_slots,a1
  433.     mulu.w        #cache_slen,d0
  434.     move.w        #ctype_texture,cache_type(a1,d0.l)
  435. *-------------------------------------------------------*
  436. *    Record this texture in graphics array        *
  437. *-------------------------------------------------------*
  438.     move.l        a4,(a5)+
  439. *-------------------------------------------------------*
  440. *    Create texture definition            *
  441. *-------------------------------------------------------*
  442.     movem.l        wt_name(a0),d0/d1
  443.     movem.l        d0/d1,tex_name(a4)
  444.     move.w        graphics_count,tex_index(a4)
  445.     imov.w        wt_width(a0),tex_width(a4)
  446.     imov.w        wt_height(a0),tex_height(a4)
  447.     imov.w        wt_patches(a0),d1
  448.     move.w        d1,tex_patches(a4)
  449.     lea        wt_len(a0),a0
  450.     lea        tex_len(a4),a4
  451.     bra.s        .copys
  452. .copy:    imov.w        wtp_xoff(a0),texp_xoff(a4)
  453.     imov.w        wtp_yoff(a0),texp_yoff(a4)
  454.     imov.w        wtp_index(a0),texp_index(a4)
  455.     lea        wtp_len(a0),a0
  456.     lea        texp_len(a4),a4
  457. .copys:    dbra        d1,.copy
  458.     rts
  459.  
  460. *-------------------------------------------------------*
  461. *    Create hashtable to reduce search overheads    *
  462. *-------------------------------------------------------*
  463. build_texture_hash:
  464. *-------------------------------------------------------*
  465.     move.l        #texture_space,texture_array
  466.     bsr        empty_hash
  467.     move.l        hash_array,a2
  468.     move.l        texturelist_array,a0
  469.     move.w        texture_count,d7
  470.     bra.s        .hashs
  471. .next:    move.l        (a0)+,a1
  472.     move.l        a1,a3
  473.     bsr.s        hash_name
  474.     move.w        #max_hash-1,d4
  475. .find:    and.w        #max_hash-1,d1
  476.     tst.l        (a2,d1.w*4)
  477.     beq.s        .slot
  478.     addq.w        #1,d1
  479.     dbra        d4,.find
  480. .slot:    move.l        a3,(a2,d1.w*4)
  481. .hashs:    dbra        d7,.next
  482.     rts
  483.  
  484. *-------------------------------------------------------*
  485. *    Find texture index using hashtable        *
  486. *-------------------------------------------------------*
  487. find_texture_index:
  488. *-------------------------------------------------------*
  489.     move.l        a0,a1
  490.     bsr        hash_name
  491.     move.l        hash_array,a2
  492.     move.w        #max_hash-1,d4
  493. .find:    and.w        #max_hash-1,d1
  494.     move.l        (a2,d1.w*4),d0
  495.     beq.s        .none
  496.     move.l        d0,a1
  497.     bsr        strcmp_8
  498.     tst.w        d0
  499.     beq.s        .cont
  500.     move.w        tex_index(a1),d0
  501.     bra.s        .done
  502. .cont:    addq.w        #1,d1
  503.     dbra        d4,.find
  504. .none:    moveq        #-1,d0
  505. .done:    rts
  506.  
  507. *-------------------------------------------------------*
  508. *    Generate hash index for 8-character name    *
  509. *-------------------------------------------------------*
  510. hash_name:
  511. *-------------------------------------------------------*
  512.     moveq        #0,d1
  513.     moveq        #1,d3
  514.     moveq        #8-1,d2
  515. .all:    moveq        #0,d0
  516.     move.b        (a1)+,d0
  517.     beq.s        .hash
  518.     fixcase        d0
  519.     sub.w        #'0',d0
  520.     muls.w        d3,d0
  521.     add.l        d0,d1
  522.     addq.w        #8,d3
  523.     dbra        d2,.all
  524. .hash:    and.w        #max_hash-1,d1
  525.     rts
  526.     
  527. *-------------------------------------------------------*
  528. *    Replace texture names with quick-index values    *
  529. *-------------------------------------------------------*
  530. replace_textures:        
  531. *-------------------------------------------------------*
  532.     Cconws        #ascii_replacetex
  533.     move.l        Side_Array,a3
  534.     move.w        NumSides,d7
  535.     bra.s        .segs
  536. .seg:    lea        sidedef_utns(a3),a0
  537.     bsr.s        replace_texname
  538.     lea        sidedef_ltns(a3),a0
  539.     bsr.s        replace_texname
  540.     lea        sidedef_mtns(a3),a0
  541.     bsr.s        replace_texname
  542.     lea        sidedef_len(a3),a3
  543. .segs:    dbra        d7,.seg
  544.     rts
  545.  
  546. *-------------------------------------------------------*
  547. *    Replace texture name with quick-index        *
  548. *-------------------------------------------------------*
  549. replace_texname:
  550. *-------------------------------------------------------*
  551.     cmp.b        #'-',(a0)
  552.     beq.s        no_texture
  553. *-------------------------------------------------------*
  554.     cmp.b        #'~',(a0)
  555.     beq.s        special_texture
  556. *-------------------------------------------------------*
  557. normal_texture:
  558. *-------------------------------------------------------*
  559.     move.l        a0,a1
  560.     bsr        hash_name
  561.     move.l        hash_array,a2
  562.     move.w        #max_hash-1,d4
  563. .find:    and.w        #max_hash-1,d1
  564.     move.l        (a2,d1.w*4),d0
  565.     beq.s        missing_texture
  566.     move.l        d0,a1
  567.     bsr        strcmp_8
  568.     tst.w        d0
  569.     beq.s        .cont
  570.     move.w        tex_index(a1),(a0)+
  571.     bra.s        texture_done
  572. .cont:    addq.w        #1,d1
  573.     dbra        d4,.find
  574. *-------------------------------------------------------*
  575. missing_texture:
  576. *-------------------------------------------------------*
  577.     move.w        #texcode_none,(a0)+
  578. ;    clr.w        (a0)+
  579.     bra.s        texture_done
  580. *-------------------------------------------------------*
  581. special_texture:
  582. *-------------------------------------------------------*
  583.     cmp.w        #'~s',(a0)
  584.     beq.s        .sky
  585.     cmp.w        #'~q',(a0)
  586.     beq.s        .qal
  587.     bra        missing_texture
  588. *-------------------------------------------------------*
  589. *    Sky texture                    *
  590. *-------------------------------------------------------*
  591. .sky:    move.w        #texcode_sky,(a0)+
  592.     bra.s        texture_done
  593. *-------------------------------------------------------*
  594. *    Quick-alpha texture                *
  595. *-------------------------------------------------------*
  596. .qal:    move.w        #texcode_qalpha,(a0)+
  597.     bra.s        texture_done
  598. *-------------------------------------------------------*
  599. no_texture:
  600. *-------------------------------------------------------*
  601.     move.w        #texcode_none,(a0)+
  602. *-------------------------------------------------------*
  603. texture_done:
  604. *-------------------------------------------------------*
  605.     clr.w        (a0)+
  606.     clr.l        (a0)+
  607.     rts
  608.  
  609. *-------------------------------------------------------*
  610. *    Wipe hashtable                    *
  611. *-------------------------------------------------------*
  612. empty_hash:
  613. *-------------------------------------------------------*
  614.     move.l        hash_array,a0
  615.     moveq        #0,d1
  616.     move.w        #max_hash-1,d0
  617. .clr:    move.l        d1,(a0)+
  618.     dbra        d0,.clr
  619.     rts
  620.  
  621. *-------------------------------------------------------*
  622. *    Simple mainloop for texture browser        *
  623. *-------------------------------------------------------*
  624. texture_loop:    
  625. *-------------------------------------------------------*
  626.     push.w        window_size
  627.     move.w        #window_max,window_size
  628.     bsr        select_window
  629.     bsr        adjust_scanlines
  630.  
  631.     moveq        #0,d0
  632.     lea        key_buffer,a6
  633.     bra        .tok
  634. .loop:
  635.     ifd        debuggable
  636.     pushall
  637.     bsr        read_key
  638.     popall
  639.     endc
  640.     tst.b        right_key(a6)
  641.     beq.s        .n1
  642.     addq.w        #1,d0
  643.     cmp.w        texture_count,d0
  644.     bmi.s        .tok
  645.     move.w        texture_count,d0
  646.     subq.w        #1,d0
  647. .tok:    pushall
  648.     move.b        #1,refresh
  649.     move.l        ScreenPhy,a0
  650.     bsr        clearscreen
  651.     popall
  652.     bsr        render_texture
  653. .n1:    tst.b        left_key(a6)
  654.     beq.s        .n2
  655.     subq.w        #1,d0
  656.     bpl.s        .ok1
  657.     moveq        #0,d0
  658. .ok1:    pushall
  659.     move.b        #1,refresh
  660.     move.l        ScreenPhy,a0
  661.     bsr        clearscreen
  662.     popall
  663.     bsr        render_texture
  664. .n2:    tst.b        text_key(a6)
  665.     beq        .loop
  666.     pop.w        window_size
  667.     bsr        select_window
  668.     rts
  669.  
  670. *-------------------------------------------------------*
  671.             bsslong
  672. *-------------------------------------------------------*
  673.  
  674. hash_array:        ds.l    1            ; misc texture pointers
  675.  
  676. graphics_array:        ds.l    1
  677. floating_array:        ds.l    1
  678. flatlist_array:        ds.l    1
  679. texturelist_array:    ds.l    1
  680. pnamelist_array:    ds.l    1
  681. texture_array:        ds.l    1
  682. flat_start:        ds.l    1
  683. flat_end:        ds.l    1
  684. patch_start:        ds.l    1
  685. patch_end:        ds.l    1
  686. resource_ptr:        ds.l    1
  687. pname_ptr:        ds.l    1
  688.  
  689. hash_space:        ds.l    max_hash        ; space for texture arrays
  690. graphics_space:        ds.l    max_graphics        ; and quicksearch hashtable
  691. pnamelist_space:    ds.l    max_textures
  692.  
  693. texture_space:        ds.b    (tex_len+(texp_len*4))*max_textures
  694.  
  695. graphics_count:        ds.w    1
  696. flat_count:        ds.w    1
  697. texture_count:        ds.w    1            
  698. pname_count:        ds.w    1            ; misc array sizes
  699.  
  700. flat_index:        ds.w    1            ; misc flat index variables
  701. sky_index:        ds.w    1
  702. current_sky:        ds.w    1
  703. sky1_index:        ds.w    1
  704. sky2_index:        ds.w    1
  705. sky3_index:        ds.w    1
  706. sky4_index:        ds.w    1
  707.  
  708. textures_present:    ds.b    1            ; flags for missing resources
  709. flats_present:        ds.b    1
  710. patches_present:    ds.b    1
  711.  
  712. *-------------------------------------------------------*
  713.             txtlong
  714. *-------------------------------------------------------*
  715.